package com.exam.suanfa;

public class BuyWater {
    public static void main(String[] args) {
        int water=buy(20,0,0);
        System.out.println(water);
    }

    private static int buy(int money, int bottle, int cap) {
        bottle=money+bottle;
        cap=money+cap;
        if (bottle/2+cap/3==0){
            return money;
        }
        int temp=buy(bottle/2+cap/3, bottle%2, cap%3);
        return money+temp;
    }
}
